<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>网页文字渐入</title>
        <link rel="stylesheet" href="style.css" />
    </head>
    <body>
        <div class="sticky">
            <h1>Less bezel, more screen.</h1>
        </div>
        <script>
            const h1 = document.querySelector("h1");

            document.addEventListener("scroll", (e) => {
                let scrolled =
                    document.documentElement.scrollTop /
                    (document.documentElement.scrollHeight -
                        document.documentElement.clientHeight);

                h1.style.setProperty("--percentage", `${scrolled * 100}%`);
            });
        </script>
    </body>
</html>
